"""
1，编写“计算机类”，属性包括CPU型号，内存大小，硬盘大小。
行为包括介绍CPU型号，展示内存大小，展示硬盘大小，综合介绍。
"""


class Computer:

    def __init__(self, **kwargs):
        self.kwargs = kwargs

    def intro_cpu(self):
        try:
            result = self.kwargs["cpu"]
        except KeyError:
            result = 'N/A'
        return result

    def intro_memory(self):
        try:
            result = self.kwargs["memory"]
        except KeyError:
            result = 'N/A'
        return result

    def intro_hardware(self):
        try:
            result = self.kwargs["hardware"]
        except KeyError:
            result = 'N/A'
        return result

    def intro_all(self):
        try:
            result = {"cpu": self.kwargs["cpu"], "memory": self.kwargs["memory"], "hardware": self.kwargs["hardware"]}
        except KeyError:
            result = 'N/A'
        return result


com1 = Computer(cpu='i9', memory='32GB', hardware='1TB')
print(f'CPU型号是 {com1.intro_cpu()}')
print(f'内存大小是 {com1.intro_memory()}')
print(f'硬盘大小是 {com1.intro_hardware()}')
print(f'CPU型号是 {com1.intro_all()["cpu"]}, 内存大小是 {com1.intro_all()["memory"]}, 硬盘大小是 {com1.intro_all()["hardware"]}')
